package tests;

import javax.vecmath.Point3d;

import primitive3D.Sphere;
import rayTracer.Ray;

public class TestSphere {

	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {		
		Sphere sphere = new Sphere();
		System.out.println(sphere);
		/*
		sphere.scale(2);
		System.out.println("\n=========> TESTING SCALE");
		System.out.println(sphere);
		
		sphere.setPosition(new Point3d(0, 0, 5));
		System.out.println("\n==========> TESTING TRANSLATION");
		System.out.println(sphere);
		*/
		// Mas tests
		
		Point3d origin = new Point3d(0,0,0);
		Sphere s = new Sphere(origin, 1.0);
		System.out.println("Esfera1: " + s);
		/*
		origin = new Point3d(-10, 3.7, -0.8);
		try {
			s = new Sphere(origin, -1.0);
			System.out.println("Esfera2: " + s);
		} catch (Exception e) {
			System.out.println("Error al crear la Esfera2");
		}
		
		s = new Sphere(origin, 3.5);
		System.out.println("Esfera3: " + s);
		
		System.out.println("Origen y Radio de la esfera3 son: ");
		System.out.println(s.getOrigin() + " y " + s.getRadius());
		
		double area = s.area();
		System.out.println("Area de la esfera3: " + area);
		
		origin = new Point3d(0,0,0);
		s = new Sphere(origin, 3.5);
		System.out.println("Esfera4: " + s);
		
		area = s.area();
		System.out.println("Area de la esfera4: " + area);
		*/
		
		// Test de interseccion
		Point3d rayOrigin = new Point3d(0,0,1);
		Point3d dir = new Point3d(0,0,0);
		Ray r = new Ray(rayOrigin,dir);
		System.out.println(r);
		
		Point3d[] pts = new Point3d[2];
		pts[0] = new Point3d();
		pts[1] = new Point3d();
		
		double dist = s.intersects(r);
		if( dist > 0 )
			System.out.print("Punto de interseccion, dist="+dist);			
		
	}

}
